<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>收货地址 - <{$common.site_name}></title>
<link rel="stylesheet" type="text/css" href="<{$common.theme}>/style/general.css" />
<link rel="stylesheet" type="text/css" href="<{$common.theme}>/style/user.css" />
<script type="text/javascript" src="<{$common.theme}>/js/jquery-1.10.2.min.js"></script>
<script type="text/javascript" src="<{$common.theme}>/js/juicer.js"></script>
<script type="text/javascript" src="<{$common.theme}>/js/general.js"></script>
<script type="text/javascript" src="<{$common.theme}>/js/consignee.js"></script>
<script type="text/javascript">
$(function(){
  initAreaSelect();
  $('#province').change(function(){
    if(this.value == ""){
      $('#city').empty().val('');
      $('#borough').empty().val('');
      return false;
    }
    $('#borough').empty().val('');
    getAreaSelect('city', '&province='+$(this).val());
  });
  $('#city').change(function(){
    if(this.value == ""){
      $('#borough').empty().val('');
      return false;
    }
    getAreaSelect('borough', '&province='+$('#province').val()+'&city='+$(this).val());
  });
});

function submitConsigneeForm(){
  if(checkConsigneeForm('consignee-form')){
    var form = $('#consignee-form');
    if(form.data('action') == 'add'){
      form.attr('action', "<{url c='consignee' a='add'}>");
    }else{
      form.attr('action', "<{url c='consignee' a='edit'}>");
    }
    form.submit();
  }
}
</script>
</head>
<body>
<!-- 顶部开始 -->
<{layout_topper common=$common}>
<!-- 顶部结束 -->
<!-- 头部开始 -->
<{layout_header common=$common}>
<!-- 头部结束 -->
<div class="loc w1100">
  <div><a href="<{$common.url}>">网站首页</a><b>></b><font>收货地址</font></div>
</div>
<!-- 主体开始 -->
<div class="container w1100 mt10">
  <div class="module cut">
    <!-- 左侧开始 -->
    <div class="w180 fl cut">
      <!-- 用户菜单开始 -->
      <{layout_usermenu}>
      <!-- 用户菜单结束 -->
    </div>
    <!-- 左侧结束 -->
    <!-- 右侧开始 -->
    <div class="w910">
      <div class="consignee mcter">
        <h2>收件地址管理</h2>
        <div class="consignee-form">
          <div><button type="button" class="sm-blue" id="new-csg-btn" onclick="showConsigneeForm('consignee-box', 'add')">+ 新建收件人信息</button></div>
          <div class="module mt10 hide cut" id="consignee-box">
            <form method="post" id="consignee-form">
              <input type="hidden" name="id" value="" />
              <div class="mcter cut">
                <dl>
                  <dt><label for="name">收件人：</label></dt>
                  <dd><input title="收件人" name="name" id="name" type="text" class="w200 txt" value="" /></dd>
                </dl>
                <dl>
                  <dt>所在地区：</dt>
                  <dd id="area-select">
                    <select title="选择省份" name="province" class="slt" id="province">
                      <option value="">选择省份</option>
                    </select>
                    <select title="选择城市" name="city" class="slt" id="city">
                      <option value="">选择城市</option>
                    </select>
                    <select title="选择区/县" name="borough" class="slt" id="borough">
                      <option value="">选择区/县</option>
                    </select>
                  </dd>
                </dl>
                <dl>
                  <dt><label for="address">详细地址：</label></dt>
                  <dd><input title="详细地址" name="address" id="address" type="text" class="w400 txt" value="" /></dd>
                </dl>
                <dl>
                  <dt><label for="zip">邮编：</label></dt>
                  <dd><input name="zip" id="zip" type="text" class="w100 txt" value="" /></dd>
                </dl>
                <dl>
                  <dt><label for="mobile_no">手机号码：</label></dt>
                  <dd><input name="mobile_no" id="mobile_no" type="text" class="w200 txt" placeholder="手机或固定电话至少填写一项" value="" /></dd>
                </dl>
                <dl>
                  <dt><label for="tel_no">固定电话：</label></dt>
                  <dd><input name="tel_no" id="tel_no" type="text" class="w200 txt" placeholder="格式：区号-电话号-分机号" value="" /></dd>
                </dl>
                <div class="submit-btn mt10">
                  <button type="button" class="sm-green mr10" onclick="submitConsigneeForm()">保存信息</button>
                  <button type="button" class="sm-gray" onclick="cancelConsigneeForm('consignee-box', 'new-csg-btn')">取消</button>
                </div>
              </div>
            </form>
          </div>
        </div>
        <div class="list mt5 cut">
          <p class="c888 ml5">您已保存了<b class="ml5 mr5 red"><{$consignee_num.total}></b>条收件人地址，还能保存<b class="ml5 mr5 red"><{$consignee_num.remaining}></b>条收件人地址</p>
          <{if !empty($consignee_list)}>
          <div class="module mt10">
            <table width="100%" border="0" cellpadding="0" cellspacing="0">
              <tr>
                <th width="130">收件人</th>
                <th>收件地址</th>
                <th width="120"><p class="aln-c">联系电话</p></th>
                <th width="110"><p class="aln-c">邮编</p></th>
                <th width="150"><p class="aln-c">操作</p></th>
              </tr>
              <{foreach $consignee_list as $v}>
              <tr>
                <td><{$v.name}></td>
                <td>
                  <p><{$v.area.province}> <{$v.area.city}> <{$v.area.borough}></p>
                  <p class="mt5"><{$v.address}></p>
                </td>
                <td><p class="aln-c"><{if !empty($v.mobile_no)}><{$v.mobile_no}><{else}><{$v.tel_no}><{/if}></p></td>
                <td><p class="aln-c"><{$v.zip}></p></td>
                <td>
                  <div class="aln-c">
                    <{if $v.is_default == 1}><font class="red ml5 mr5">默认地址</font><{else}><a href="<{url c='consignee' a='setdef' id=$v.id}>">设为默认</a><{/if}>
                    <a onclick="getConsigneeInfo('consignee-box', '<{$v.id}>')">编辑</a>
                    <a href="<{url c='consignee' a='delete' id=$v.id}>">删除</a>
                  </div>
                </td>
              </tr>
              <{/foreach}>
            </table>
          </div>
          <{/if}>
        </div>
      </div>
    </div>
    <!-- 右侧结束 -->
  </div>
  <div class="cl"></div>
  <{layout_helper}>
</div>
<!-- 主体结束 -->
<div class="cl"></div>
<!-- 页脚开始 -->
<{layout_footer}>
<!-- 页脚结束 -->
</body>
</html>